﻿using HY.Common;
using HY.Entity;
using HY.Service;
using HY.Web.Controllers;
using HY.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HY.Web.Areas.Shop.Controllers
{
    public class AdvertController : BaseController
    {
        BaseService service = new BaseService();
        // GET: Shop/Advert
        public ActionResult Index()
        {
            return View();
        }
        
        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult Index(int page, int limit)
        {
            ReturnModel returnModel = new ReturnModel();
            try
            {
                var where = $"IsDeleted=0";
                var tuple = service.GetPageList<Advert>("Advert", "*", where, page, limit, "CreateDate desc");
                returnModel = base.GetReturnModel(tuple.Item1, tuple.Item2);
            }
            catch (Exception ex)
            {
                returnModel = base.GetReturnModel(ex);
                LogHelper.Error("查询推荐图片列表", ex);
            }
            return Json(returnModel);
        }
    }
}